package com.shop2cn.iapi.sellerpromotion.testcase;

import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.shop2cn.iapi.sellerpromotion.parameter.CreatePromotionBean;
import com.shop2cn.iapi.sellerpromotion.parameter.PromotionItem;
import com.shop2cn.iapi.sellerpromotion.parameter.PromotionListBean;
import com.shop2cn.iapi.sellerpromotion.parameter.PromotionListVo;
import com.shop2cn.iapi.sellerpromotion.service.PromotionListCall;
import com.ymt.core.tool.FormatUtil;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.Shop2cnSellerPromotionCallService;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
import com.ymttest.database.mongo.Shop2cnSellerPromotionInfoWapper;
import com.ymttest.utils.YMTDateUtil;
/**
*满减列表
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_PromotionList{
	private static PromotionListBean promotionlistBean;
	private static PromotionListCall promotionlistCall;
	private static Integer mchId;
	private static Shop2cnSellerPromotionInfoWapper Shop2cnSellerPromotionInfoWapper;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("满减列表");
		try {
			Shop2cnSellerPromotionInfoWapper=new Shop2cnSellerPromotionInfoWapper();
			mchId=GodmchManageCallService.CreateSellerMch();
		} catch (Exception e) {
		}
	}

	@Before
	public void caseUp() {
		promotionlistBean=new PromotionListBean();
		promotionlistCall=new PromotionListCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(promotionlistCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
		try {
			Shop2cnSellerPromotionCallService.EndAllEnablePromotion(mchId);
		} catch (IOException e) {
//			e.printStackTrace();
		}
	}
	private void verifyDB(List<PromotionListVo> promotionList, int status) throws Exception {
		for (PromotionListVo promotionListVo : promotionList) {
			Map m = Shop2cnSellerPromotionInfoWapper.getPromotionById(promotionListVo.getPromotionId());
			Logger.verifyEquals(promotionListVo.getName(), m.get("name"), "验证name");
			//新增 20200729 是否显示在首页
			Logger.verifyEquals(promotionListVo.getShowHomePage(), m.get("shp"), "验证shp");
			
//			Logger.verifyEquals(createpromotionBean2.getPromotionInfo().getPromotionDesc(), m.get("des"), "验证des");
			if (promotionListVo.getBegin().compareTo(YMTDateUtil.getBeforeOrNextDay(0, YMTDateUtil.YMDHMS)) > 0) {
				Logger.verifyEquals(promotionListVo.getBegin().substring(0, 16),
						YMTDateUtil.getFromDTSDate(m.get("bt").toString(), YMTDateUtil.YMDHMS).substring(0, 16), "验证bt");
			} else {
				Logger.verifyNotNull(YMTDateUtil.getFromDTSDate(m.get("bt").toString(), YMTDateUtil.YMDHMS), "验证bt");
			}

			Logger.verifyEquals(promotionListVo.getEnd().substring(0, 16),
					YMTDateUtil.getFromDTSDate(m.get("et").toString(), YMTDateUtil.YMDHMS).substring(0, 16), "验证et");
			
			if(status>=0) {
				Integer mystatus=Shop2cnSellerPromotionCallService.getStatus(YMTDateUtil.getFromDTSDate(m.get("bt").toString(), YMTDateUtil.YMDHMS), YMTDateUtil.getFromDTSDate(m.get("et").toString(), YMTDateUtil.YMDHMS));
				Logger.verifyEquals(status, mystatus, "验证status");
			}
			List<String> vlist = promotionListVo.getValueList();
			List<Map> lm = (List<Map>) m.get("vs");
			for (int i=0;i<lm.size();i++) {
				Map vsm = lm.get(i);
				
				String info=Shop2cnSellerPromotionCallService.getValue(Integer.valueOf(m.get("type").toString()), new BigDecimal(vsm.get("rv").toString()), new BigDecimal(vsm.get("dv").toString()));
				
				
				if((boolean)vsm.get("ff")==true && vsm.get("rg")!=null )
					info+="，部分地区包邮";
				else if((boolean)vsm.get("ff")==true && vsm.get("rg")==null )
					info+="，全国包邮";
				  Logger.verifyEquals(vlist.get(i), info, "验证valueList"+i);
				  Logger.comment("id:"+m.get("_id"));
				  Logger.comment("info:"+info);
			}
		}
		
		
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_PromotionList_001() {
		Logger.start(true,"查询全部满减列表成功,status-1,type=3满额减");
		try {
			Integer status=-1;
			//已开始 多层级
			CreatePromotionBean createpromotionBean = Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			PromotionItem e=new PromotionItem();
			e.setLevel(1);
			e.setUseCondition(BigDecimal.valueOf(200));
			e.setValue(BigDecimal.valueOf(20));
			createpromotionBean.getPromotionItemList().add(e);
			Integer promotionId = Shop2cnSellerPromotionCallService.CreatepromotionCall(createpromotionBean);
			Thread.sleep(2000);
			//未开始
			createpromotionBean = Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.setBegin(YMTDateUtil.getBeforeOrNextDay(1,"yyyy-MM-dd HH:mm:ss"));
			createpromotionBean.setEnd(YMTDateUtil.getBeforeOrNextDay(2,"yyyy-MM-dd HH:mm:ss"));
			Shop2cnSellerPromotionCallService.CreatepromotionCall(createpromotionBean);
			
			Thread.sleep(1000);
			
			promotionlistBean.setSellerId(mchId);
			promotionlistBean.setStatus(status);
			promotionlistBean.setPageIndex(1);
			promotionlistBean.setPageSize(10);
			promotionlistCall.setData(promotionlistBean);
			promotionlistCall.callService();			
			Logger.verifyEquals("200", promotionlistCall.getString("code"), "验证返回");
			Logger.verifyEquals(true, promotionlistCall.getJsonObject().get("data").getAsJsonObject().get("total").getAsInt()>0, "验证返回总数大于0");
			Logger.debug(FormatUtil.beanToGSONString(promotionlistCall.getPromotionList()));
			verifyDB(promotionlistCall.getPromotionList(),status);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	

	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_PromotionList_002() {
		Logger.start(true,"不输入sellerid失败");
		try {
			promotionlistBean.setPageIndex(1);
			promotionlistBean.setPageSize(1);
			promotionlistBean.setStatus(-1);
			promotionlistCall.setData(promotionlistBean);
			promotionlistCall.callService();			
			Logger.verifyEquals("400", promotionlistCall.getString("code"), "验证code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_PromotionList_003() {
		Logger.start(true,"不输入status失败");
		try {
			promotionlistBean.setPageIndex(1);
			promotionlistBean.setPageSize(1);
			promotionlistBean.setSellerId(3383);
			promotionlistCall.setData(promotionlistBean);
			promotionlistCall.callService();			
			Logger.verifyEquals("400", promotionlistCall.getString("code"), "验证code");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_PromotionList_004() {
		Logger.start(true,"不输入pageIndex默认1");
		try {
			promotionlistBean.setStatus(-1);
//			promotionlistBean.setPageIndex(1);
			promotionlistBean.setPageSize(1);
			promotionlistBean.setSellerId(3383);
			promotionlistCall.setData(promotionlistBean);
			promotionlistCall.callService();			
			Logger.verifyEquals("200", promotionlistCall.getString("code"), "验证code");
			//手工校验有返回 受静态数据影响
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_PromotionList_005() {
		Logger.start(true,"不输入pageSize取默认值-5");
		try {
			promotionlistBean.setStatus(-1);
			promotionlistBean.setPageIndex(1);
//			promotionlistBean.setPageSize(1);
			promotionlistBean.setSellerId(3383);
			promotionlistCall.setData(promotionlistBean);
			promotionlistCall.callService();			
			Logger.verifyEquals("200", promotionlistCall.getString("code"), "验证code");
			//手工校验有返回 受静态数据影响
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_PromotionList_006() {
		Logger.start(true,"查询未开始满减列表成功,status-0");
		try {
			Integer mchId2 = GodmchManageCallService.CreateSellerMch();
			Integer status=0;
			CreatePromotionBean createpromotionBean = Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId2, 3);
			createpromotionBean.setBegin(YMTDateUtil.getBeforeOrNextDay(1,"yyyy-MM-dd HH:mm:ss"));
			createpromotionBean.setEnd(YMTDateUtil.getBeforeOrNextDay(2,"yyyy-MM-dd HH:mm:ss"));
			Integer promotionId = Shop2cnSellerPromotionCallService.CreatepromotionCall(createpromotionBean);
			Thread.sleep(1000);
			promotionlistBean.setSellerId(mchId2);
			promotionlistBean.setStatus(status);
			promotionlistBean.setPageIndex(1);
			promotionlistBean.setPageSize(10);
			promotionlistCall.setData(promotionlistBean);
			promotionlistCall.callService();			
			Logger.verifyEquals("200", promotionlistCall.getString("code"), "验证返回");
			Logger.debug(FormatUtil.beanToGSONString(promotionlistCall.getPromotionList()));
			Logger.verifyEquals(true, promotionlistCall.getJsonObject().get("data").getAsJsonObject().get("total").getAsInt()>0, "验证返回总数大于0");
			verifyDB(promotionlistCall.getPromotionList(),status);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_PromotionList_007() {
		Logger.start(true,"查询已开始满减列表成功,status-1");
		try {
			Integer status=1;
			//已开始
			CreatePromotionBean createpromotionBean = Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.setBegin(YMTDateUtil.getBeforeOrNextDay(0,"yyyy-MM-dd HH:mm:ss"));
			createpromotionBean.setEnd(YMTDateUtil.getBeforeOrNextDay(2,"yyyy-MM-dd HH:mm:ss"));
			Shop2cnSellerPromotionCallService.CreatepromotionCall(createpromotionBean);
			
			Thread.sleep(1000);
			promotionlistBean.setSellerId(mchId);
			promotionlistBean.setStatus(status);
			promotionlistBean.setPageIndex(1);
			promotionlistBean.setPageSize(10);
			promotionlistCall.setData(promotionlistBean);
			promotionlistCall.callService();			
			Logger.verifyEquals("200", promotionlistCall.getString("code"), "验证返回");
			Logger.debug(FormatUtil.beanToGSONString(promotionlistCall.getPromotionList()));
			Logger.verifyEquals(true, promotionlistCall.getJsonObject().get("data").getAsJsonObject().get("total").getAsInt()>0, "验证返回总数大于0");
			verifyDB(promotionlistCall.getPromotionList(),status);
			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_PromotionList_008() {
		Logger.start(true,"查询已结束满减列表成功,status-2");
		try {
			Integer status=2;
			//已开始
			CreatePromotionBean createpromotionBean = Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.setBegin(YMTDateUtil.getBeforeOrNextDay(0,"yyyy-MM-dd HH:mm:ss"));
			createpromotionBean.setEnd(YMTDateUtil.getBeforeOrNextDay(2,"yyyy-MM-dd HH:mm:ss"));
			Integer promotionId = Shop2cnSellerPromotionCallService.CreatepromotionCall(createpromotionBean);
			Shop2cnSellerPromotionCallService.PromotionEnd(mchId, promotionId);
			Thread.sleep(1000);
			promotionlistBean.setSellerId(mchId);
			promotionlistBean.setStatus(status);
			promotionlistBean.setPageIndex(1);
			promotionlistBean.setPageSize(10);
			promotionlistCall.setData(promotionlistBean);
			promotionlistCall.callService();			
			Logger.verifyEquals("200", promotionlistCall.getString("code"), "验证返回");
			Logger.debug(FormatUtil.beanToGSONString(promotionlistCall.getPromotionList()));
			Logger.verifyEquals(true, promotionlistCall.getJsonObject().get("data").getAsJsonObject().get("total").getAsInt()>0, "验证返回总数大于0");
			verifyDB(promotionlistCall.getPromotionList(),status);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_PromotionList_009() {
		Logger.start(true,"不会查询出已删除");
		try {
			Integer status=-1;
			//已开始
			CreatePromotionBean createpromotionBean = Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.setBegin(YMTDateUtil.getBeforeOrNextDay(0,"yyyy-MM-dd HH:mm:ss"));
			createpromotionBean.setEnd(YMTDateUtil.getBeforeOrNextDay(2,"yyyy-MM-dd HH:mm:ss"));
			Integer promotionId = Shop2cnSellerPromotionCallService.CreatepromotionCall(createpromotionBean);
			Shop2cnSellerPromotionCallService.PromotionDelete(mchId, promotionId);
			
			Thread.sleep(1000);
			promotionlistBean.setSellerId(mchId);
			promotionlistBean.setStatus(status);
			promotionlistBean.setPageIndex(1);
			promotionlistBean.setPageSize(10);
			promotionlistCall.setData(promotionlistBean);
			promotionlistCall.callService();			
			Logger.verifyEquals("200", promotionlistCall.getString("code"), "验证返回");
			Logger.debug(FormatUtil.beanToGSONString(promotionlistCall.getPromotionList()));
			if(promotionlistCall.getPromotionList()!=null&&promotionlistCall.getPromotionList().size()>0) {
				promotionlistCall.getPromotionList().forEach(pl->{
					Logger.verifyNotEquals(promotionId, pl.getPromotionId(), "验证不存在已删除promotionId:"+promotionId);
				});
			}
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_PromotionList_010() {
		Logger.start(true,"分页查询全部满减列表成功");
		try {
			Integer status=-1;
			//已开始
			CreatePromotionBean createpromotionBean = Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.setBegin(YMTDateUtil.getBeforeOrNextDay(0,"yyyy-MM-dd HH:mm:ss"));
			createpromotionBean.setEnd(YMTDateUtil.getBeforeOrNextDay(1,"yyyy-MM-dd HH:mm:ss"));
			Shop2cnSellerPromotionCallService.CreatepromotionCall(createpromotionBean);
			Thread.sleep(1000);
			//未开始
			createpromotionBean = Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.setBegin(YMTDateUtil.getBeforeOrNextDay(1,"yyyy-MM-dd HH:mm:ss"));
			createpromotionBean.setEnd(YMTDateUtil.getBeforeOrNextDay(2,"yyyy-MM-dd HH:mm:ss"));
			Shop2cnSellerPromotionCallService.CreatepromotionCall(createpromotionBean);
			
			promotionlistBean.setSellerId(mchId);
			promotionlistBean.setStatus(status);
			promotionlistBean.setPageIndex(1);
			promotionlistBean.setPageSize(1);
			promotionlistCall.setData(promotionlistBean);
			promotionlistCall.callService();			
			Logger.verifyEquals("200", promotionlistCall.getString("code"), "验证返回");
			Logger.debug(FormatUtil.beanToGSONString(promotionlistCall.getPromotionList()));
			Logger.verifyEquals(true, promotionlistCall.getJsonObject().get("data").getAsJsonObject().get("total").getAsInt()>0, "验证返回总数大于0");
			verifyDB(promotionlistCall.getPromotionList(),status);
			
			promotionlistBean.setSellerId(mchId);
			promotionlistBean.setStatus(status);
			promotionlistBean.setPageIndex(2);
			promotionlistBean.setPageSize(1);
			promotionlistCall.setData(promotionlistBean);
			promotionlistCall.callService();			
			Logger.verifyEquals("200", promotionlistCall.getString("code"), "验证返回");
			Logger.debug(FormatUtil.beanToGSONString(promotionlistCall.getPromotionList()));
			Logger.verifyEquals(true, promotionlistCall.getJsonObject().get("data").getAsJsonObject().get("total").getAsInt()>0, "验证返回总数大于0");
			verifyDB(promotionlistCall.getPromotionList(),status);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_PromotionList_011() {
		Logger.start(true,"查询全部满减列表成功,status-1,type=1满件减");
		try {
			Integer status=-1;
			CreatePromotionBean createpromotionBean = Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 1);
			Integer promotionId = Shop2cnSellerPromotionCallService.CreatepromotionCall(createpromotionBean);
			promotionlistBean.setSellerId(mchId);
			promotionlistBean.setStatus(status);
			promotionlistBean.setPageIndex(1);
			promotionlistBean.setPageSize(10);
			promotionlistCall.setData(promotionlistBean);
			promotionlistCall.callService();			
			Logger.verifyEquals("200", promotionlistCall.getString("code"), "验证返回");
			Logger.debug(FormatUtil.beanToGSONString(promotionlistCall.getPromotionList()));
			verifyDB(promotionlistCall.getPromotionList(),status);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_PromotionList_012() {
		Logger.start(true,"查询全部满减列表成功,status-1,type=2满件折");
		try {
			Integer status=-1;
			CreatePromotionBean createpromotionBean = Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 2);
			Integer promotionId = Shop2cnSellerPromotionCallService.CreatepromotionCall(createpromotionBean);
			promotionlistBean.setSellerId(mchId);
			promotionlistBean.setStatus(status);
			promotionlistBean.setPageIndex(1);
			promotionlistBean.setPageSize(10);
			promotionlistCall.setData(promotionlistBean);
			promotionlistCall.callService();			
			Logger.verifyEquals("200", promotionlistCall.getString("code"), "验证返回");
			Logger.debug(FormatUtil.beanToGSONString(promotionlistCall.getPromotionList()));
			verifyDB(promotionlistCall.getPromotionList(),status);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_PromotionList_013() {
		Logger.start(true,"查询全部满减列表成功,status-1,type=4满额折");
		try {
			Integer status=-1;
			CreatePromotionBean createpromotionBean = Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 4);
			Integer promotionId = Shop2cnSellerPromotionCallService.CreatepromotionCall(createpromotionBean);
			promotionlistBean.setSellerId(mchId);
			promotionlistBean.setStatus(status);
			promotionlistBean.setPageIndex(1);
			promotionlistBean.setPageSize(10);
			promotionlistCall.setData(promotionlistBean);
			promotionlistCall.callService();			
			Logger.verifyEquals("200", promotionlistCall.getString("code"), "验证返回");
			Logger.debug(FormatUtil.beanToGSONString(promotionlistCall.getPromotionList()));
			verifyDB(promotionlistCall.getPromotionList(),status);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_PromotionList_014() {
		Logger.start(true,"查询全部满减列表成功,status-1,type=3满额减,全部地区包邮");
		try {
			Integer status=-1;
			//已开始 多层级
			CreatePromotionBean createpromotionBean = Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			PromotionItem e=new PromotionItem();
			e.setLevel(1);
			e.setUseCondition(BigDecimal.valueOf(200));
			e.setValue(BigDecimal.valueOf(20));
			createpromotionBean.getPromotionItemList().add(e);
			//新增 包邮20191227
			createpromotionBean.getPromotionItemList().get(0).setfreeFreight(true);
			
			Integer promotionId = Shop2cnSellerPromotionCallService.CreatepromotionCall(createpromotionBean);
			Thread.sleep(2000);
			//未开始
			createpromotionBean = Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.setBegin(YMTDateUtil.getBeforeOrNextDay(1,"yyyy-MM-dd HH:mm:ss"));
			createpromotionBean.setEnd(YMTDateUtil.getBeforeOrNextDay(2,"yyyy-MM-dd HH:mm:ss"));
			Shop2cnSellerPromotionCallService.CreatepromotionCall(createpromotionBean);
			
			Thread.sleep(1000);
			
			promotionlistBean.setSellerId(mchId);
			promotionlistBean.setStatus(status);
			promotionlistBean.setPageIndex(1);
			promotionlistBean.setPageSize(10);
			promotionlistCall.setData(promotionlistBean);
			promotionlistCall.callService();			
			Logger.verifyEquals("200", promotionlistCall.getString("code"), "验证返回");
			Logger.verifyEquals(true, promotionlistCall.getJsonObject().get("data").getAsJsonObject().get("total").getAsInt()>0, "验证返回总数大于0");
			Logger.debug(FormatUtil.beanToGSONString(promotionlistCall.getPromotionList()));
			verifyDB(promotionlistCall.getPromotionList(),status);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_PromotionList_015() {
		Logger.start(true,"查询全部满减列表成功,status-1,type=3满额减,一个地区包邮-上海包邮");
		try {
			Integer status=-1;
			//已开始 多层级
			CreatePromotionBean createpromotionBean = Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			PromotionItem e=new PromotionItem();
			e.setLevel(1);
			e.setUseCondition(BigDecimal.valueOf(200));
			e.setValue(BigDecimal.valueOf(20));
			createpromotionBean.getPromotionItemList().add(e);
			//新增 包邮20191227
			createpromotionBean.getPromotionItemList().get(0).setfreeFreight(true);
			List<String> freeRegions=new ArrayList<>();
			freeRegions.add("上海");
			createpromotionBean.getPromotionItemList().get(0).setFreeRegions(freeRegions);
			
			
			Integer promotionId = Shop2cnSellerPromotionCallService.CreatepromotionCall(createpromotionBean);
			Thread.sleep(2000);
			//未开始
			createpromotionBean = Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.setBegin(YMTDateUtil.getBeforeOrNextDay(1,"yyyy-MM-dd HH:mm:ss"));
			createpromotionBean.setEnd(YMTDateUtil.getBeforeOrNextDay(2,"yyyy-MM-dd HH:mm:ss"));
			Shop2cnSellerPromotionCallService.CreatepromotionCall(createpromotionBean);
			
			Thread.sleep(1000);
			
			promotionlistBean.setSellerId(mchId);
			promotionlistBean.setStatus(status);
			promotionlistBean.setPageIndex(1);
			promotionlistBean.setPageSize(10);
			promotionlistCall.setData(promotionlistBean);
			promotionlistCall.callService();			
			Logger.verifyEquals("200", promotionlistCall.getString("code"), "验证返回");
			Logger.verifyEquals(true, promotionlistCall.getJsonObject().get("data").getAsJsonObject().get("total").getAsInt()>0, "验证返回总数大于0");
			Logger.debug(FormatUtil.beanToGSONString(promotionlistCall.getPromotionList()));
			verifyDB(promotionlistCall.getPromotionList(),status);
		} catch (Exception e) {
			Logger.fail(e);
		}
		
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_PromotionList_016() {
		Logger.start(true,"查询全部满减列表成功,status-1,type=3满额减,两个地区包邮-上海、北京包邮");
		
		try {
			Integer status=-1;
			//已开始 多层级
			CreatePromotionBean createpromotionBean = Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			PromotionItem e=new PromotionItem();
			e.setLevel(1);
			e.setUseCondition(BigDecimal.valueOf(200));
			e.setValue(BigDecimal.valueOf(20));
			createpromotionBean.getPromotionItemList().add(e);
			//新增 包邮20191227
			createpromotionBean.getPromotionItemList().get(0).setfreeFreight(true);
			List<String> freeRegions=new ArrayList<>();
			freeRegions.add("上海");
			freeRegions.add("北京");
			createpromotionBean.getPromotionItemList().get(0).setFreeRegions(freeRegions);
			
			
			Integer promotionId = Shop2cnSellerPromotionCallService.CreatepromotionCall(createpromotionBean);
			Thread.sleep(2000);
			//未开始
			createpromotionBean = Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.setBegin(YMTDateUtil.getBeforeOrNextDay(1,"yyyy-MM-dd HH:mm:ss"));
			createpromotionBean.setEnd(YMTDateUtil.getBeforeOrNextDay(2,"yyyy-MM-dd HH:mm:ss"));
			Shop2cnSellerPromotionCallService.CreatepromotionCall(createpromotionBean);
			
			Thread.sleep(1000);
			
			promotionlistBean.setSellerId(mchId);
			promotionlistBean.setStatus(status);
			promotionlistBean.setPageIndex(1);
			promotionlistBean.setPageSize(10);
			promotionlistCall.setData(promotionlistBean);
			promotionlistCall.callService();			
			Logger.verifyEquals("200", promotionlistCall.getString("code"), "验证返回");
			Logger.verifyEquals(true, promotionlistCall.getJsonObject().get("data").getAsJsonObject().get("total").getAsInt()>0, "验证返回总数大于0");
			Logger.debug(FormatUtil.beanToGSONString(promotionlistCall.getPromotionList()));
			verifyDB(promotionlistCall.getPromotionList(),status);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_PromotionList_017() {
		Logger.start(true,"查询全部满减列表成功,是否显示在首页ShowHomePage=true");
		try {
			Integer status=-1;
			//已开始 多层级
			CreatePromotionBean createpromotionBean = Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			PromotionItem e=new PromotionItem();
			e.setLevel(1);
			e.setUseCondition(BigDecimal.valueOf(200));
			e.setValue(BigDecimal.valueOf(20));
			createpromotionBean.getPromotionItemList().add(e);
			Integer promotionId = Shop2cnSellerPromotionCallService.CreatepromotionCall(createpromotionBean);
			Thread.sleep(2000);
			//未开始
			createpromotionBean = Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.setBegin(YMTDateUtil.getBeforeOrNextDay(1,"yyyy-MM-dd HH:mm:ss"));
			createpromotionBean.setEnd(YMTDateUtil.getBeforeOrNextDay(2,"yyyy-MM-dd HH:mm:ss"));
			
			createpromotionBean.setShowHomePage(true);
			Shop2cnSellerPromotionCallService.CreatepromotionCall(createpromotionBean);
			
			Thread.sleep(1000);
			
			promotionlistBean.setSellerId(mchId);
			promotionlistBean.setStatus(status);
			promotionlistBean.setPageIndex(1);
			promotionlistBean.setPageSize(10);
			promotionlistCall.setData(promotionlistBean);
			promotionlistCall.callService();			
			Logger.verifyEquals("200", promotionlistCall.getString("code"), "验证返回");
			Logger.verifyEquals(true, promotionlistCall.getJsonObject().get("data").getAsJsonObject().get("total").getAsInt()>0, "验证返回总数大于0");
			Logger.debug(FormatUtil.beanToGSONString(promotionlistCall.getPromotionList()));
			verifyDB(promotionlistCall.getPromotionList(),status);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_PromotionList_018() {
		Logger.start(true,"提前结束活动-status=0 未开始，查询不到-20200916 ");
		try {
			Integer mchId2 = GodmchManageCallService.CreateSellerMch();
			Integer status=0;
			CreatePromotionBean createpromotionBean = Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId2, 3);
			createpromotionBean.setBegin(YMTDateUtil.getBeforeOrNextDay(1,"yyyy-MM-dd HH:mm:ss"));
			createpromotionBean.setEnd(YMTDateUtil.getBeforeOrNextDay(2,"yyyy-MM-dd HH:mm:ss"));
			Integer promotionId = Shop2cnSellerPromotionCallService.CreatepromotionCall(createpromotionBean);
			
			Shop2cnSellerPromotionCallService.PromotionEnd(mchId2,promotionId);
			
			Thread.sleep(1000);
			promotionlistBean.setSellerId(mchId2);
			promotionlistBean.setStatus(status);
			promotionlistBean.setPageIndex(1);
			promotionlistBean.setPageSize(10);
			promotionlistCall.setData(promotionlistBean);
			promotionlistCall.callService();			
			Logger.verifyEquals("200", promotionlistCall.getString("code"), "验证返回");
			Logger.debug(FormatUtil.beanToGSONString(promotionlistCall.getPromotionList()));
			Logger.verifyEquals(true, promotionlistCall.getJsonObject().get("data").getAsJsonObject().get("total").getAsInt()==0, "验证返回总数大于0");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}